﻿using DosTexPrj.Core.Models;
using FluentNHibernate.Mapping;

namespace DosTexPrj.Implement.NHibernate.Mapping
{
    public class UserMapping : ClassMap<User>
    {
        public UserMapping()
        {
            Table("Users");
            Id(x => x.Id, "UserID").GeneratedBy.Identity()
                                    .UnsavedValue(0);
            Map(x => x.FirstName, "FirstName").Not.Nullable().Length(50);
            Map(x => x.LastName, "LastName").Not.Nullable().Length(50);
            Map(x => x.Username, "UserName").Not.Nullable().Length(50);
            Map(x => x.Password, "Password").Not.Nullable().Length(100);
            References<Role>(x => x.Role).Column("RoleID");
        }
    }
}